<template>
    <div>
        <el-table :data="tableData1" border>
            <el-table-column align="center" label="名称" prop="name"></el-table-column>
            <el-table-column align="center" label="介绍名称" prop="desc"></el-table-column>
            <el-table-column align="center" label="标签" prop="tag"></el-table-column>
            <el-table-column align="center" label="优惠券类型" prop="type"></el-table-column>
            <el-table-column align="center" label="最低消费" prop="min"></el-table-column>
            <el-table-column align="center" label="优惠面值" prop="discount"></el-table-column>
        </el-table>

        <el-table :data="tableData1" border>
            <el-table-column align="center" label="每人限额" prop="limit"></el-table-column>
            <el-table-column align="center" label="当前状态" prop="status"></el-table-column>
            <el-table-column align="center" label="商品范围" prop="test"></el-table-column>
            <el-table-column align="center" label="有效期" prop="days"></el-table-column>
            <el-table-column align="center" label="优惠兑换码" prop="code"></el-table-column>
            <el-table-column align="center" label="发行数量" prop="total"></el-table-column>
        </el-table>

        <br>
        <hr>
        <br>
        <el-table :data="tableData2" border>
            <el-table-column align="center" label="名称" prop="id"></el-table-column>
            <el-table-column align="center" label="介绍名称" prop="name"></el-table-column>
            <el-table-column align="center" label="标签" prop="desc"></el-table-column>
            <el-table-column align="center" label="优惠券类型" prop="tag"></el-table-column>
            <el-table-column align="center" label="最低消费" prop="min"></el-table-column>
            <el-table-column align="center" label="优惠面值" prop="discount"></el-table-column>
        </el-table>
    </div>
</template>

<script>
import axios from 'axios'
    export default {
        data () {
            return {
                tableData1: [],
                tableData2: []
            }
        },
        mounted () {
            this.getTableData1()
            this.getTableData2()
        },
        methods: {
            getTableData1 () {
                axios({
                    url: 'http://192.168.200.251:8888/admin/coupon/read',
                    method: 'get',
                    params: {
                        id: this.$route.query.id
                    },
                    headers: {
                        'Shopping-Admin-Token': sessionStorage.getItem('Shopping-Admin-Token')
                    }
                }).then(res => {
                    console.log('tableData1', res)
                    this.tableData1 = [res.data.data]
                })
            },
            getTableData2 () {
                axios({
                    url: 'http://192.168.200.251:8888/admin/coupon/listuser',
                    method: 'get',
                    params: {
                        couponId: this.$route.query.id,
                        page: 1,
                        limit: 10000
                    },
                    headers: {
                        'Shopping-Admin-Token': sessionStorage.getItem('Shopping-Admin-Token')
                    }
                }).then(res => {
                    console.log('tableData2', res)

                    this.tableData2 = res.data.data.list
                })
            },
        }
    }
</script>